from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:joshua@localhost/guess'
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True)
    login = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(25), unique=True)

    def __init__(self, name, login, password):
        self.name = name
        self.email = email
        self.password = password

    def __repr__(self):
        return '<User %r>' % self.name

class Player(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True)
    login = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(25), unique=True)

    def __init__(self, name, login, password):
        self.name = name
        self.email = email
        self.password = password

    def __repr__(self):
        return '<Player %r>' % self.name

class Team(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return '<Team %r' % self.name

class Game(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.DateTime)
    result = db.Column(db.String(80))
    location = db.Column(db.Strin(80))
    teamOne = db.Column(db.Integer, db.ForeignLey('team.id'))
    teamTwo = db.Column(db.Integer, db.ForeignLey('team.id'))

    def __init__(self, time, result, location, teamOne, teamTwo):
        self.time = time
        self.result = result
        self.location = location
        self.teamOne = teamOne
        self.teamTwo = teamTwo

    def __repr__(self):
        return '<Game %r vs %r' % (self.teamOne, self.teamTwo)

class Bet(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    time = db.Column(db.DateTime)
    playerId = db.Column(db.Integer, db.ForeignLey('player.id'))
    gameId = db.Column(db.Integer, db.ForeignLey('game.id'))
    teamId = db.Column(db.Integer, db.ForeignLey('team.id'))

    def __init__(self, time, playerId, gameId, teamId):
        self.name = name
        self.time = time
        self.playerId = playerId
        self.gameId = gameId
        self.teamId = teamId

    def __repr__(self):
        return '<Bet %r' % self.name
